package com.atguigu.rabbitmq.five;

import com.atguigu.rabbitmq.utils.RabbitMqutils;
import com.rabbitmq.client.Channel;

import java.io.IOException;
import java.util.Scanner;
import java.util.concurrent.TimeoutException;

/**
 * 发消息给交换机
 */
public class EmitLog {
    //交换机的名字
    public static final String EXCHANGE_NAME = "logs";

    public static void main(String[] args) throws IOException, TimeoutException {
        Channel channel = RabbitMqutils.getChannel();
        //交互机
       // channel.exchangeDeclare(EXCHANGE_NAME,"fauout");
        Scanner scanner = new Scanner(System.in);

        while (scanner.hasNext()){
            String message = scanner.next();
            channel.basicPublish(EXCHANGE_NAME,"",null,message.getBytes("utf-8"));
            System.out.println("生产者发出的消息是什么"+message);
        }

    }
}
